﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SERP.StringMappings;
using SERP.DAO;
using SERP.Controllers;
namespace SERP.Modules.WorkPositions{
	public partial class WorkPositionsViewInfo : SERP.Modules.ModuleBase
	{
		private WorkPositionsController controller = new WorkPositionsController();
		public WorkPositionsController Controller{
			get{
				return controller;
			} 
		}
		protected void Page_Load(object sender, EventArgs e){
    		LoadLanguage();	
			if(!this.IsPostBack){		
				BindInfo();	
			}
		}
		//Load All lable text
		private void LoadLanguage(){
			labelPosName.Text=WorkPositionsStringMapping.PosName+":";
			labelNote.Text=WorkPositionsStringMapping.Note+":";
			labelBinaryId.Text=WorkPositionsStringMapping.BinaryId+":";
		}
		public WorkPositionsEntity GetObject(){
			controller.LoadObject(Int32.Parse(Request["PositionId"]));
			return controller.WorkPositionsObject;
		}
		private void BindInfo(){
			WorkPositionsEntity o=GetObject();		
			CopyToSreen(o);
			BindBinaryId(o);
		}
		private void BindBinaryId(WorkPositionsEntity o){
			BinaryDataController ctrlBinaryData = new BinaryDataController();
			ctrlBinaryData.LoadObject(o.BinaryId);
			BinaryDataEntity oBinaryData=ctrlBinaryData.BinaryDataObject;
			if(oBinaryData!=null){
				txtBinaryId.Text = oBinaryData.FileName.ToString();
			}
			else{
				txtBinaryId.Text = "";
			}
		}
		private void CopyToSreen(WorkPositionsEntity o){
			txtPosName.Text=o.PosName;
			txtNote.Text=o.Note;
		}   
}
}
